<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- | POSIX time, if you need to deal with timestamps and the like.</span><span>
</span><span id="line-2"></span><span class="hs-comment">-- Most people won't need this module.</span><span>
</span><span id="line-3"></span><span class="hs-comment">--</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- You can use 'POSIXTime' to obtain integer/word timestamps. For example:</span><span>
</span><span id="line-5"></span><span class="hs-comment">--</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- &gt; import Data.Time</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- &gt; import Data.Time.Clock.POSIX</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- &gt; import Data.Int</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- &gt;</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- &gt; nanosSinceEpoch :: UTCTime -&gt; Int64</span><span>
</span><span id="line-11"></span><span class="hs-comment">-- &gt; nanosSinceEpoch =</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- &gt;     floor . (1e9 *) . nominalDiffTimeToSeconds . utcTimeToPOSIXSeconds</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- &gt;</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- &gt; main :: IO ()</span><span>
</span><span id="line-15"></span><span class="hs-comment">-- &gt; main = do</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- &gt;     u &lt;- getCurrentTime</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- &gt;     print $ nanosSinceEpoch u</span><span>
</span><span id="line-18"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Time.Clock.POSIX</span><span>
</span><span id="line-19"></span><span class="hs-special">(</span><span>
</span><span id="line-20"></span><span>    </span><span class="annot"><a href="Data.Time.Clock.Internal.POSIXTime.html#posixDayLength"><span class="hs-identifier">posixDayLength</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Data.Time.Clock.Internal.POSIXTime.html#POSIXTime"><span class="hs-identifier">POSIXTime</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Data.Time.Clock.POSIX.html#posixSecondsToUTCTime"><span class="hs-identifier">posixSecondsToUTCTime</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Data.Time.Clock.POSIX.html#utcTimeToPOSIXSeconds"><span class="hs-identifier">utcTimeToPOSIXSeconds</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Data.Time.Clock.POSIX.html#getPOSIXTime"><span class="hs-identifier">getPOSIXTime</span></a></span><span class="hs-special">,</span><span class="annot"><a href="Data.Time.Clock.POSIX.html#getCurrentTime"><span class="hs-identifier">getCurrentTime</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>    </span><span class="annot"><a href="Data.Time.Clock.POSIX.html#systemToPOSIXTime"><span class="hs-identifier">systemToPOSIXTime</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-23"></span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.POSIXTime.html"><span class="hs-identifier">Data.Time.Clock.Internal.POSIXTime</span></a></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.UTCTime.html"><span class="hs-identifier">Data.Time.Clock.Internal.UTCTime</span></a></span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Time.Clock.System.html"><span class="hs-identifier">Data.Time.Clock.System</span></a></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Data.Time.Calendar.Days.html"><span class="hs-identifier">Data.Time.Calendar.Days</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Fixed.html#"><span class="hs-identifier">Data.Fixed</span></a></span><span>
</span><span id="line-29"></span><span>
</span><span id="line-30"></span><span class="annot"><a href="Data.Time.Clock.POSIX.html#posixSecondsToUTCTime"><span class="hs-identifier hs-type">posixSecondsToUTCTime</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.POSIXTime.html#POSIXTime"><span class="hs-identifier hs-type">POSIXTime</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span>
</span><span id="line-31"></span><span id="posixSecondsToUTCTime"><span class="annot"><span class="annottext">posixSecondsToUTCTime :: POSIXTime -&gt; UTCTime
</span><a href="Data.Time.Clock.POSIX.html#posixSecondsToUTCTime"><span class="hs-identifier hs-var hs-var">posixSecondsToUTCTime</span></a></span></span><span> </span><span id="local-6989586621679070782"><span class="annot"><span class="annottext">POSIXTime
</span><a href="#local-6989586621679070782"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span>
</span><span id="line-32"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679070778"><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679070778"><span class="hs-identifier hs-var">d</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679070777"><span class="annot"><span class="annottext">POSIXTime
</span><a href="#local-6989586621679070777"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">POSIXTime -&gt; POSIXTime -&gt; (Integer, POSIXTime)
forall a b. (Real a, Integral b) =&gt; a -&gt; a -&gt; (b, a)
</span><a href="../../base/src/Data.Fixed.html#divMod%27"><span class="hs-identifier hs-var">divMod'</span></a></span><span> </span><span class="annot"><span class="annottext">POSIXTime
</span><a href="#local-6989586621679070782"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">POSIXTime
</span><a href="Data.Time.Clock.Internal.POSIXTime.html#posixDayLength"><span class="hs-identifier hs-var">posixDayLength</span></a></span><span>
</span><span id="line-33"></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">Day -&gt; DiffTime -&gt; UTCTime
</span><a href="Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-var">UTCTime</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; Day -&gt; Day
</span><a href="Data.Time.Calendar.Days.html#addDays"><span class="hs-identifier hs-var">addDays</span></a></span><span> </span><span class="annot"><span class="annottext">Integer
</span><a href="#local-6989586621679070778"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">Day
</span><a href="Data.Time.Clock.System.html#systemEpochDay"><span class="hs-identifier hs-var">systemEpochDay</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">POSIXTime -&gt; DiffTime
forall a b. (Real a, Fractional b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#realToFrac"><span class="hs-identifier hs-var">realToFrac</span></a></span><span> </span><span class="annot"><span class="annottext">POSIXTime
</span><a href="#local-6989586621679070777"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span class="annot"><a href="Data.Time.Clock.POSIX.html#utcTimeToPOSIXSeconds"><span class="hs-identifier hs-type">utcTimeToPOSIXSeconds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.POSIXTime.html#POSIXTime"><span class="hs-identifier hs-type">POSIXTime</span></a></span><span>
</span><span id="line-36"></span><span id="utcTimeToPOSIXSeconds"><span class="annot"><span class="annottext">utcTimeToPOSIXSeconds :: UTCTime -&gt; POSIXTime
</span><a href="Data.Time.Clock.POSIX.html#utcTimeToPOSIXSeconds"><span class="hs-identifier hs-var hs-var">utcTimeToPOSIXSeconds</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span> </span><span id="local-6989586621679070772"><span class="annot"><span class="annottext">Day
</span><a href="#local-6989586621679070772"><span class="hs-identifier hs-var">d</span></a></span></span><span> </span><span id="local-6989586621679070771"><span class="annot"><span class="annottext">DiffTime
</span><a href="#local-6989586621679070771"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-37"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Integer -&gt; POSIXTime
forall a. Num a =&gt; Integer -&gt; a
</span><a href="../../base/src/GHC.Num.html#fromInteger"><span class="hs-identifier hs-var">fromInteger</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Day -&gt; Day -&gt; Integer
</span><a href="Data.Time.Calendar.Days.html#diffDays"><span class="hs-identifier hs-var">diffDays</span></a></span><span> </span><span class="annot"><span class="annottext">Day
</span><a href="#local-6989586621679070772"><span class="hs-identifier hs-var">d</span></a></span><span> </span><span class="annot"><span class="annottext">Day
</span><a href="Data.Time.Clock.System.html#systemEpochDay"><span class="hs-identifier hs-var">systemEpochDay</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">POSIXTime -&gt; POSIXTime -&gt; POSIXTime
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">POSIXTime
</span><a href="Data.Time.Clock.Internal.POSIXTime.html#posixDayLength"><span class="hs-identifier hs-var">posixDayLength</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">POSIXTime -&gt; POSIXTime -&gt; POSIXTime
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="annot"><span class="annottext">POSIXTime -&gt; POSIXTime -&gt; POSIXTime
forall a. Ord a =&gt; a -&gt; a -&gt; a
</span><span class="hs-identifier hs-var">min</span></span><span> </span><span class="annot"><span class="annottext">POSIXTime
</span><a href="Data.Time.Clock.Internal.POSIXTime.html#posixDayLength"><span class="hs-identifier hs-var">posixDayLength</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DiffTime -&gt; POSIXTime
forall a b. (Real a, Fractional b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#realToFrac"><span class="hs-identifier hs-var">realToFrac</span></a></span><span> </span><span class="annot"><span class="annottext">DiffTime
</span><a href="#local-6989586621679070771"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="annot"><a href="Data.Time.Clock.POSIX.html#systemToPOSIXTime"><span class="hs-identifier hs-type">systemToPOSIXTime</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.SystemTime.html#SystemTime"><span class="hs-identifier hs-type">SystemTime</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.POSIXTime.html#POSIXTime"><span class="hs-identifier hs-type">POSIXTime</span></a></span><span>
</span><span id="line-40"></span><span id="systemToPOSIXTime"><span class="annot"><span class="annottext">systemToPOSIXTime :: SystemTime -&gt; POSIXTime
</span><a href="Data.Time.Clock.POSIX.html#systemToPOSIXTime"><span class="hs-identifier hs-var hs-var">systemToPOSIXTime</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Time.Clock.Internal.SystemTime.html#MkSystemTime"><span class="hs-identifier hs-type">MkSystemTime</span></a></span><span> </span><span id="local-6989586621679070765"><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621679070765"><span class="hs-identifier hs-var">s</span></a></span></span><span> </span><span id="local-6989586621679070764"><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621679070764"><span class="hs-identifier hs-var">ns</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int64 -&gt; POSIXTime
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Int64
</span><a href="#local-6989586621679070765"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">POSIXTime -&gt; POSIXTime -&gt; POSIXTime
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2B"><span class="hs-operator hs-var">+</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word32 -&gt; POSIXTime
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="../../base/src/GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">Word32
</span><a href="#local-6989586621679070764"><span class="hs-identifier hs-var">ns</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">POSIXTime -&gt; POSIXTime -&gt; POSIXTime
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#%2A"><span class="hs-operator hs-var">*</span></a></span><span> </span><span class="annot"><span class="annottext">POSIXTime
</span><span class="hs-number">1E-9</span></span><span>
</span><span id="line-41"></span><span>
</span><span id="line-42"></span><span class="hs-comment">-- | Get the current POSIX time from the system clock.</span><span>
</span><span id="line-43"></span><span class="annot"><a href="Data.Time.Clock.POSIX.html#getPOSIXTime"><span class="hs-identifier hs-type">getPOSIXTime</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.POSIXTime.html#POSIXTime"><span class="hs-identifier hs-type">POSIXTime</span></a></span><span>
</span><span id="line-44"></span><span id="getPOSIXTime"><span class="annot"><span class="annottext">getPOSIXTime :: IO POSIXTime
</span><a href="Data.Time.Clock.POSIX.html#getPOSIXTime"><span class="hs-identifier hs-var hs-var">getPOSIXTime</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(SystemTime -&gt; POSIXTime) -&gt; IO SystemTime -&gt; IO POSIXTime
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">SystemTime -&gt; POSIXTime
</span><a href="Data.Time.Clock.POSIX.html#systemToPOSIXTime"><span class="hs-identifier hs-var">systemToPOSIXTime</span></a></span><span> </span><span class="annot"><span class="annottext">IO SystemTime
</span><a href="Data.Time.Clock.Internal.SystemTime.html#getSystemTime"><span class="hs-identifier hs-var">getSystemTime</span></a></span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="hs-comment">-- | Get the current 'UTCTime' from the system clock.</span><span>
</span><span id="line-47"></span><span class="annot"><a href="Data.Time.Clock.POSIX.html#getCurrentTime"><span class="hs-identifier hs-type">getCurrentTime</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IO</span></span><span> </span><span class="annot"><a href="Data.Time.Clock.Internal.UTCTime.html#UTCTime"><span class="hs-identifier hs-type">UTCTime</span></a></span><span>
</span><span id="line-48"></span><span id="getCurrentTime"><span class="annot"><span class="annottext">getCurrentTime :: IO UTCTime
</span><a href="Data.Time.Clock.POSIX.html#getCurrentTime"><span class="hs-identifier hs-var hs-var">getCurrentTime</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SystemTime -&gt; UTCTime
</span><a href="Data.Time.Clock.System.html#systemToUTCTime"><span class="hs-identifier hs-var">systemToUTCTime</span></a></span><span> </span><span class="annot"><span class="annottext">(SystemTime -&gt; UTCTime) -&gt; IO SystemTime -&gt; IO UTCTime
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-operator hs-var">`fmap`</span></a></span><span> </span><span class="annot"><span class="annottext">IO SystemTime
</span><a href="Data.Time.Clock.Internal.SystemTime.html#getSystemTime"><span class="hs-identifier hs-var">getSystemTime</span></a></span><span>
</span><span id="line-49"></span></pre></body></html>